package net.qiqbframework.eventhandling;

import lombok.extern.slf4j.Slf4j;

import javax.annotation.Nonnull;

@Slf4j
public class LoggingErrorHandler implements ListenerInvocationErrorHandler {


    @Override
    public void onError(@Nonnull Exception exception, @Nonnull EventMessage<?> event,
                        @Nonnull EventMessageHandler eventHandler) {
        log.error("EventListener [{}] failed to handle event [{}] ({}). " +
                        "Continuing processing with next listener",
                eventHandler.getTargetType().getSimpleName(),
                event.getIdentifier(),
                event.getPayloadType().getName(),
                exception);
    }
}
